package com.ruoyi.web.controller.system;

import com.ruoyi.web.service.C2PipelineRunningStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/C2PipelineRunningStatus")
public class C2PipelineRunningStatusController {

    @Autowired
    private C2PipelineRunningStatusService c2PipelineRunningStatusService;

    /**
     * 获取当天每个 CICD 的 Pipeline 运行状态统计数据
     * @return JSON 数据
     */
    @GetMapping("/byDay")
    public ResponseEntity<Map<String, Map<String, Object>>> getPipelineRunningStatusByDay() {
        // 调用 Service 层获取统计数据
        Map<String, Map<String, Object>> statistics = c2PipelineRunningStatusService.getCICDStatistics();

        // 返回 JSON 响应
        return ResponseEntity.ok(statistics);
    }
}
